package com.demo.system.controller;

import com.demo.common.entity.User;
import com.demo.system.service.UserService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户账户(User)控制器
 *
 * @author why
 * @since 2025-09-17 15:18:52
 */
@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {


    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    // 获取所有记录
    @GetMapping
    public List<User> getAll() {
        return userService.list();
    }

    // 根据ID获取单个记录
    @GetMapping("/{id}")
    public User getById(@PathVariable("id") Long id) {
        return userService.getById(id);
    }
}
